package com.com.effectivejava.serializability.util;

import java.io.Closeable;
import java.lang.reflect.Method;

/**
 * Created by pankaj on 7/19/14.
 */
public class Cleanup {
    private Cleanup(){

    }

    public static void closeQuietly(Closeable closeable){
        if(null == closeable)
            return;
        try{
            closeable.close();
        }catch (Exception e){

        }
    }

    public static void closeQuitely(Object closeable){
        if(null == closeable){
            return;
        }
        try{
            Class<?> [] params = new Class<?>[0];
            Method closeMethod = closeable.getClass().getMethod("close", params);
            Object[] args = new Object[0];
            closeMethod.invoke(closeable, args);
        }catch (Exception e){

        }
    }


}
